﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebApi.Filter
{
    public class CustomRouteAttribute : RouteAttribute, IApiDescriptionGroupNameProvider
    {
        public string GroupName { get; set; }

        //public CustomRouteAttribute(string version) : base($"/api/{version.ToString()}/[controller]")
        //{
        //    GroupName = version.ToString();
        //}

        /// <summary>
        /// 自定义版本+路由构造函数，继承基类路由
        /// </summary>

        /// <param name="version"></param>
        /// 喜欢这种路由
        public CustomRouteAttribute(string version) : base($"/api/{version.ToString()}/[controller]/[action]")
        {
            GroupName = version.ToString();
        }
    }
}
